package cn.edu.scau.cmi.lishuoxin.client.experiment5;

import cn.edu.scau.cmi.lishuoxin.interProgramming.experiment5.Folder;
import cn.edu.scau.cmi.lishuoxin.interProgramming.experiment5.ImageFile;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class GroupMain extends Application{
	@Override
	public void start(Stage primaryStage) throws Exception {
		try {
			Folder folder = new Folder();
			Pane root = new Pane();
			Button button1 = new Button("创建主文件夹");
			button1.setOnAction(e -> {
				folder.setName("主文件夹");
				System.out.println("创建主文件夹成功！");
			});
			button1.setLayoutX(0);
			button1.setLayoutY(10.0);
			root.getChildren().add(button1);
			
			ImageFile image1 = new ImageFile();
			Button button2 = new Button("创建山河图片");
			button2.setOnAction(e -> {
				image1.setName("山河.jpg");
				System.out.println("创建图片成功！");
			});
			button2.setLayoutX(0);
			button2.setLayoutY(60.0);
			root.getChildren().add(button2);
			
			ImageFile image2 = new ImageFile();
			Button button3 = new Button("创建高楼图片");
			button3.setOnAction(e -> {
				image2.setName("高楼.png");
				System.out.println("创建图片成功！");
			});
			button3.setLayoutX(0);
			button3.setLayoutY(110.0);
			root.getChildren().add(button3);
			
			Button button4 = new Button("添加图片到主文件夹");
			button4.setOnAction(e -> {
				folder.add(image1);
				folder.add(image2);
			});
			button4.setLayoutX(0);
			button4.setLayoutY(160.0);
			root.getChildren().add(button4);
			
			Button button5 = new Button("下载山河图片");
			button5.setOnAction(e -> {
				image1.downloadFile();
				System.out.println("----------------------");
			});
			button5.setLayoutX(0);
			button5.setLayoutY(210.0);
			root.getChildren().add(button5);
			
			Button button6 = new Button("下载文件夹中的图片");
			button6.setOnAction(e -> {
				folder.downloadFile();
				System.out.println("----------------------");
			});
			button6.setLayoutX(0);
			button6.setLayoutY(260.0);
			root.getChildren().add(button6);
			
			Button button7 = new Button("上传山河图片");
			button7.setOnAction(e -> {
				image1.uploadFile();
				System.out.println("----------------------");
			});
			button7.setLayoutX(0);
			button7.setLayoutY(310.0);
			root.getChildren().add(button7);
			
			Scene scene = new Scene(root,500,400);
			primaryStage.setTitle("组合模式");
			primaryStage.setScene(scene);
			primaryStage.show();
		} catch(Exception e) {
			e.printStackTrace();
		}
	
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		launch(args);
	}
}
